Option Explicit On 

Imports System.Collections.Specialized

Public Class CommandSwitches

   Dim CmdSwitches As New StringDictionary

   Sub New(ByVal CmdArgs() As String)

      Dim Cmd As String
      For Each Cmd In CmdArgs
         Cmd = Trim(Cmd)
         If Cmd <> "" Then
            If Cmd.StartsWith("/") And Cmd.IndexOf(":") > 2 Then
               CmdSwitches.Add(Cmd.Substring(1, Cmd.IndexOf(":") - 1), Cmd.Substring(Cmd.IndexOf(":") + 1))
            End If
         End If
      Next

   End Sub

   Public Function GetSwitch(ByVal Key As String, ByVal Def As String) As String
      If Me.Switch(Key) <> "" Then
         Return Me.Switch(Key)
      Else
         Return Def
      End If
   End Function


   Default Public ReadOnly Property Switch(ByVal Key As String) As String

      Get
         If CmdSwitches.ContainsKey(Key) Then
            Return CmdSwitches(Key)
         Else
            Return ""
         End If
      End Get

   End Property

End Class
